package net.cyan.proteus.compile;

import net.cyan.proteus.base.*;
import net.cyan.proteus.base.logic.*;
import net.cyan.proteus.compile.logic.*;

/**
 * 
 * @author camel
 * @date 2008-4-10
 */
public class BaseTemplateCompiler extends TemplateCompiler
{
    public BaseTemplateCompiler(TemplateClassMaker classMaker)
    {
        super(classMaker);

        addElementCompiler(ElElement.class, new ElCompiler());
        addElementCompiler(ScriptElement.class, new ScriptCompiler());
        addElementCompiler(TagElement.class, new TagCompiler());
        addElementCompiler(SegmentElement.class, new SegmentCompiler());

        LogicCompiler logicCompiler = new LogicCompiler();
        logicCompiler.addStatementCompiler(IfStatement.class, new IfCompiler());
        logicCompiler.addStatementCompiler(ForStatement.class, new ForCompiler());
        logicCompiler.addStatementCompiler(WhileStatement.class, new WhileCompiler());
        logicCompiler.addStatementCompiler(AssignStatement.class, new AssignCompiler());
        logicCompiler.addStatementCompiler(BreakStatement.class, new BreakCompiler());
        logicCompiler.addStatementCompiler(ContinueStatement.class, new ContinueCompiler());
        addElementCompiler(LogicElement.class, logicCompiler);
        addElementCompiler(MacroElement.class, new MacroCompiler());

        addElementCompiler(MacroCallElement.class, new MacroCallCompiler());
        addElementCompiler(NestedElement.class, new NestedCompiler());
    }

    public BaseTemplateCompiler()
    {
        this(DefaultClassMaker.getInstance());
    }
}
